package com.sds.sweng.swat.miplatform.ui.design.models.component;

import org.apache.commons.lang.StringUtils;

import com.sds.sweng.swat.miplatform.ui.design.figures.geps.GepsTab;
import com.sds.sweng.swat.miplatform.ui.design.figures.logical.TabInfo;
import com.sds.sweng.swat.miplatform.ui.design.models.MiplatformComponent;
import com.sds.sweng.swat.miplatform.ui.design.models.MiplatformDesignModel;

public class MTab extends MiplatformComponent {

	private int type;
	private boolean selected;
	private String url;
	private MiplatformDesignModel tabContents;

	public MTab() {

	}

	public MTab(String text, int type) {
		this.type = type;

		setText(text);

		tabContents = new MiplatformDesignModel(StringUtils.EMPTY, MForm.TYPE_TAB_PAGE);
	}

	public MTab clone() {
		MTab clone = (MTab) super.clone();
		clone.setType(getType());
		clone.setSelected(isSelected());
		clone.setUrl(getUrl());
		clone.setTabContents(getTabContents().clone());
		clone.refresh();

		return clone;
	}

	public void refresh() {
		TabInfo tabInfo = GepsTab.getTabInfo(type, text);
		setImageId(tabInfo.imageId);
		setStyle(tabInfo.style);
		setWidth(tabInfo.width);
		setHeight(tabInfo.height);
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public MiplatformDesignModel getTabContents() {
		return tabContents;
	}

	public void setTabContents(MiplatformDesignModel tabContents) {
		this.tabContents = tabContents;
	}

	public boolean isSelected() {
		return selected;
	}

	public void setSelected(boolean selected) {
		this.selected = selected;
	}

}
